import random

money = random.randint(1000,10000)
jia=0
goodlist = [
    {"name":"apple","price":"10"},
    {"name":"banana","price":"5"},
    {"name":"watermalen","price":"15"}
]
gcarlist = []
e=0
a=input("请输入开始进行抽奖")
if a=="开始":
    b=random.randint(1,10)
    print("恭喜，您的优惠是",b)
print('展示商品')
for product in goodlist:
    print(product)
    print()
while True:
   x = input('请输入商品')
   if x.lower()=='q':
       break
   if x.lower()=='w':
       c=input("请输入要退的商品")
       for d in gcarlist:
           if c.lower()==d["name"].lower():
               jia-=int(d["price"])/b
               gcarlist.pop(e)
               break
           elif c!=d["name"]:
               e+=1
   f=0
   for g in goodlist:
     if x.lower() ==g["name"].lower():
        if money<int(g["price"])/b:
            print('穷鬼，钱不够！您的余额还剩',money,'请到其他超市购买')
            f+=1
        else:
            gcarlist.append(g)
            money -= int(g["price"])/b
            jia+=int(g["price"])/b
            print('恭喜，购买成功！您的卡余额还有',money)
            f+=1
        break
   if f==0:
         print('没有这个商品，别瞎搞！')
if not gcarlist:
    print("\n🛒 您的购物车是空的，没有购买任何商品")
print("\n====== 购物小票 ======")
print('               ','商品','    ' '价格')
print(gcarlist)
print('总计',jia)
print("======================")
